package com.xinda.admin.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * 
	* <p>Title:ChartController </p>
	* <p>Description: 系统统计</p>
	* <p>Company: </p> 
	* @author Administrator
	* @date 2017年8月23日下午4:21:59
 */

import com.xinda.admin.service.ChartService;
import com.xinda.admin.vo.CountAdminByMonthVO;
import com.xinda.admin.vo.CountMemberByMonthVO;
import com.xinda.admin.vo.CountMoneyByMonthVO;
import com.xinda.admin.vo.CountOrderByMonthVO;
import com.xinda.admin.vo.CountProviderByMonthVO;

@Controller
public class ChartController {
	@Resource
	private ChartService chartService;
	
	/**
	 * 折线图
	 * @return
	 */
	@RequestMapping(value = "lineChart")
	public String lineChart() {
		return "admin/charts/lineChart";
	}
	
	/**
	 * 统计管理员数据
	 * @return
	 */
	@RequestMapping(value = "countAdminData")
	@ResponseBody
	public List<Integer> countAdminData() {
		List<CountAdminByMonthVO> listVO = new ArrayList<CountAdminByMonthVO>();
		List<Integer> adminChartList = new ArrayList<Integer>();
		for (int i = 0; i < 12; i++) {
			adminChartList.add(0);
		}
		listVO = chartService.countAdminByMonth();
		for (int j = 0; j < 11; j++) {
			adminChartList.set(j, 0);
			for (int i = 0; i < listVO.size(); i++) {
				
					if (listVO.get(i).getMonth()-1==j) {
						
						adminChartList.set(j, listVO.get(i).getCountAdmin());
					}
				}
		}

		return adminChartList;
	}
	
	/**
	 * 统计用户数据
	 * @return
	 */
	@RequestMapping(value = "countMemberData")
	@ResponseBody
	public List<Integer> countMemberData() {
		List<CountMemberByMonthVO> listVO = new ArrayList<CountMemberByMonthVO>();
		List<Integer> memberChartList = new ArrayList<Integer>();
		for (int i = 0; i < 12; i++) {
			memberChartList.add(0);
		}
		listVO = chartService.countMemberByMonth();
		for (int j = 0; j < 11; j++) {
			memberChartList.set(j, 0);
			for (int i = 0; i < listVO.size(); i++) {
				
					if (listVO.get(i).getMonth()-1==j) {
						
						memberChartList.set(j, listVO.get(i).getCountMember());
					}
				}
		}
		return memberChartList;
	}
	
	/**
	 * 统计服务商数据
	 * @return
	 */
	@RequestMapping(value = "countProviderData")
	@ResponseBody
	public List<Integer> countProviderByMonth() {
		List<CountProviderByMonthVO> listVO = new ArrayList<CountProviderByMonthVO>();
		List<Integer> providerChartList = new ArrayList<Integer>();
		for (int i = 0; i < 12; i++) {
			providerChartList.add(0);
		}
		listVO = chartService.countProviderByMonth();
		for (int j = 0; j < 11; j++) {
			providerChartList.set(j, 0);
			for (int i = 0; i < listVO.size(); i++) {
				
					if (listVO.get(i).getMonth()-1==j) {
						
						providerChartList.set(j, listVO.get(i).getCountProvider());
					}
				}
		}
		return providerChartList;
	}
	
	
	/**
	 * 统计交易总额
	 * @return
	 */
	@RequestMapping(value = "countMoneyData")
	@ResponseBody
	public List<Integer> countMoneyData() {
		List<CountMoneyByMonthVO> listVO = new ArrayList<CountMoneyByMonthVO>();
		List<Integer> moneyChartList = new ArrayList<Integer>();
		for (int i = 0; i < 12; i++) {
			moneyChartList.add(0);
		}
		listVO = chartService.countMoneyByMonth();
		for (int j = 0; j < 11; j++) {
			moneyChartList.set(j, 0);
			for (int i = 0; i < listVO.size(); i++) {
				
					if (listVO.get(i).getMonth()-1==j) {
						
						moneyChartList.set(j, listVO.get(i).getCountMoney());
					}
				}
		}

		return moneyChartList;
	}
	
	
	/**
	 * 统计订单数量
	 * @return
	 */
	@RequestMapping(value = "countOrderData")
	@ResponseBody
	public List<Integer> countOrderData() {
		List<CountOrderByMonthVO> listVO = new ArrayList<CountOrderByMonthVO>();
		List<Integer> orderChartList = new ArrayList<Integer>();
		for (int i = 0; i < 12; i++) {
			orderChartList.add(0);
		}
		listVO = chartService.countOrderByMonth();

		for (int j = 0; j < 11; j++) {
			orderChartList.set(j, 0);
			for (int i = 0; i < listVO.size(); i++) {
				
					if (listVO.get(i).getMonth()-1==j) {
						
						orderChartList.set(j, listVO.get(i).getCountOrder());
					}
				}
		}

		return orderChartList;
	}
	
	/**
	 * 统计订单数量
	 * @return
	 */
	@RequestMapping(value = "countProductOne")
	@ResponseBody
	public Integer countProductOne() {	
		Integer countProduct= chartService.countProductOne();
		return countProduct;
	}
	
	@RequestMapping(value = "countProductTwo")
	@ResponseBody
	public Integer countProductTwo() {	
		Integer countProduct= chartService.countProductTwo();
		return countProduct;
	}
	
	@RequestMapping(value = "countProductThree")
	@ResponseBody
	public Integer countProductThree() {	
		Integer countProduct= chartService.countProductThree();
		return countProduct;
	}
	@RequestMapping(value = "countProductFour")
	@ResponseBody
	public Integer countProductFour() {	
		Integer countProduct= chartService.countProductFour();
		return countProduct;
	}
	
	/**
	 * 时间轴折线图
	 * @return
	 */
	@RequestMapping(value = "timelineChart")
	public String timelineChart() {
		return "admin/charts/timelineChart";
	}
	
	/**
	 * 区域图
	 * @return
	 */
	@RequestMapping(value = "areaChart")
	public String areaChart() {
		return "admin/charts/areaChart";
	}
	
	
	/**
	 * 柱状图
	 * @return
	 */
	@RequestMapping(value = "barChart")
	public String barChart() {
		return "admin/charts/barChart";
	}
	
	/**
	 * 饼状图
	 * @return
	 */
	@RequestMapping(value = "pieChart")
	public String pieChart() {
		return "admin/charts/pieChart";
	}
	
	/**
	 * 3D柱状图
	 * @return
	 */
	@RequestMapping(value = "barChartTD")
	public String barChartTD() {
		return "admin/charts/barChartTD";
	}
	
	/**
	 * 3D饼状图
	 * @return
	 */
	@RequestMapping(value = "pieChartTD")
	public String pieChartTD() {
		return "admin/charts/pieChartTD";
	}

}
